package com.alliky.core.manage

import com.alliky.common.entity.User
import com.alliky.common.global.Global
import com.alliky.core.utils.SPUtils.Companion.getObject
import com.alliky.core.utils.SPUtils.Companion.saveObject

/**
 * @Author: wxianing
 * @CreateDate: 2022/3/3 22:26
 * @Description: java类作用描述
 */
class UserManage {

    companion object {
        @Volatile
        private var userManger: UserManage? = null
        val instance: UserManage?
            get() {
                if (null == userManger) {
                    synchronized(UserManage::class.java) {
                        if (null == userManger) {
                            userManger = UserManage()
                        }
                    }
                }
                return userManger
            }
    }

    fun setUser(user: User?) {
        saveObject(Global.KEY.USER_INFO, user)
    }

    val User by lazy {
        getObject(Global.KEY.USER_INFO, User::class.java)
    }

    val isLogin by lazy {
        User != null
    }

}